package com.ruoyi.archive.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.archive.domain.SLivingConditionInfo;
import com.ruoyi.archive.service.ISLivingConditionInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生活状况模块Controller
 * 
 * @author Allen
 * @date 2021-10-08
 */
@RestController
@RequestMapping("/archive_info/living_condition_info")
public class SLivingConditionInfoController extends BaseController
{
    @Autowired
    private ISLivingConditionInfoService sLivingConditionInfoService;

    /**
     * 查询生活状况模块列表
     */
    @PreAuthorize("@ss.hasPermi('archive_info:living_condition_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(SLivingConditionInfo sLivingConditionInfo)
    {
        startPage();
        List<SLivingConditionInfo> list = sLivingConditionInfoService.selectSLivingConditionInfoList(sLivingConditionInfo);
        return getDataTable(list);
    }

    /**
     * 导出生活状况模块列表
     */
    @PreAuthorize("@ss.hasPermi('archive_info:living_condition_info:export')")
    @Log(title = "生活状况模块", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SLivingConditionInfo sLivingConditionInfo)
    {
        List<SLivingConditionInfo> list = sLivingConditionInfoService.selectSLivingConditionInfoList(sLivingConditionInfo);
        ExcelUtil<SLivingConditionInfo> util = new ExcelUtil<SLivingConditionInfo>(SLivingConditionInfo.class);
        return util.exportExcel(list, "生活状况模块数据");
    }

    /**
     * 获取生活状况模块详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive_info:living_condition_info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sLivingConditionInfoService.selectSLivingConditionInfoById(id));
    }

    /**
     * 新增生活状况模块
     */
    @PreAuthorize("@ss.hasPermi('archive_info:living_condition_info:add')")
    @Log(title = "生活状况模块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SLivingConditionInfo sLivingConditionInfo)
    {
        return toAjax(sLivingConditionInfoService.insertSLivingConditionInfo(sLivingConditionInfo));
    }

    /**
     * 修改生活状况模块
     */
    @PreAuthorize("@ss.hasPermi('archive_info:living_condition_info:edit')")
    @Log(title = "生活状况模块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SLivingConditionInfo sLivingConditionInfo)
    {
        return toAjax(sLivingConditionInfoService.updateSLivingConditionInfo(sLivingConditionInfo));
    }

    /**
     * 删除生活状况模块
     */
    @PreAuthorize("@ss.hasPermi('archive_info:living_condition_info:remove')")
    @Log(title = "生活状况模块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sLivingConditionInfoService.deleteSLivingConditionInfoByIds(ids));
    }
}
